package com.xing.algorithm.array;

import java.util.HashSet;
import java.util.Set;

public class ContainsDuplicate {
    public static boolean containsDuplicate(int[] nums) {
        if(nums == null) {
            return false;
        }
        if(nums.length == 0) {
            return false;
        }

        Set<Integer> set = new HashSet<Integer>();
        for(int i = 0; i < nums.length; i ++) {
            if(set.contains(nums[i])) {
                return true;
            } else {
                set.add(nums[i]);
            }
        }

        return false;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{1,1,2,3,4,5,6,7};
        System.out.println(containsDuplicate(nums));
    }
}
